#include "fonctions_player.h"
#include "constantes_player.h"

bool validMovePosition(player p, player o, int dx, int dy)
{
	return (moveRectangle(&(p.perso.fight.position),dx,dy) == 0) && !superpositionRectangle(p.perso.fight.position, o.perso.fight.position);
}
bool validChgPosition(player p, player o, int dw, int dh)
{
	return (resizeRectangle(&(p.perso.fight.position),dh,dw) == 0) && !superpositionRectangle(p.perso.fight.position, o.perso.fight.position);
}

void movePosition(player *p, player o, int dx, int dy)
{
	moveRectangle(&(p->perso.fight.position), dx, dy);
}
bool movePositionTested(player *p, player o, int dx, int dy)
{
	bool f = validMovePosition(*p,o,dx,dy);
	if (f)
		movePosition(p, o, dx, dy);
	return f;
}
void chgPosition(player *p, player o, int dw, int dh)
{
	resizeRectangle(&(p->perso.fight.position), dw, dh);
}

bool isLeftPerso(player p, player o)
{
	return p.perso.fight.position.point.x <= o.perso.fight.position.point.x;
}
bool chgPositionTested(player *p, player o, int dw, int dh)
{
	bool f = validChgPosition(*p,o,dw,dh);
	if (f)
		chgPosition(p, o, dw, dh);
	return f;
}